package com.geekstudy.week3;

import com.geekstudy.week3.http.HttpClientProvider;
import com.geekstudy.week3.http.HttpInterface;
import com.geekstudy.week3.http.HttpOKProvider;

public class HttpTool {

    public static final String HTTP_CLIENT = "HTTP_CLIENT";
    public static final String HTTP_OK = "HTTP_OK";


    public String get(String url) {
        return get(url, HTTP_CLIENT);
    }

    public String get(String url, String httpProvider) {
        String response = null;
        HttpInterface http = null;
        if(HTTP_CLIENT.equals(httpProvider)) {
            http = new HttpClientProvider();
        } else if(HTTP_OK.equals(httpProvider)) {
            http = new HttpOKProvider();
        } else {
            System.out.println("HttpTool use default provider ");
            http = new HttpClientProvider();
        }

        response = http.get(url);
        return response;
    }


}
